package com.example.imoocmall.controller;

import com.example.imoocmall.common.ApiRestResponse;
import com.example.imoocmall.service.OrderAdminService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 后天订单管理
 */
@RestController
@RequestMapping("/admin/order")
@Api(tags = "订单后台管理")
public class OrderAdminController {

    @Autowired
    OrderAdminService orderAdminService;

    @ApiOperation("管理员订单列表")
    @GetMapping("/list")
    public ApiRestResponse listForAdmin(@RequestParam Integer pageNum, @RequestParam Integer pageSize){
        PageInfo pageInfo = orderAdminService.listForAdmin(pageNum, pageSize);
        return ApiRestResponse.success(pageInfo);
    }

    @ApiOperation("管理员发货")
    @GetMapping("/delivered")
    public ApiRestResponse delivered(@RequestParam String orderNo){
        orderAdminService.delivered(orderNo);
        return ApiRestResponse.success();
    }
}
